package com.dongdongshop.controller;

import com.dongdongshop.pojo.TbContent;
import com.dongdongshop.service.ContentService;
import com.dongdongshop.util.Result;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("content")
public class ContentController {

    @DubboReference(timeout = 1000000)
    private ContentService cs;

    @RequestMapping("getContentByCategoryId")
    @ResponseBody
    public Result getContentByCategoryId(Integer categoryId, @RequestParam(defaultValue = "5")Integer pageSize){
        try {
            List<TbContent> contentList = cs.getContentByCategoryId(categoryId,pageSize);
            return Result.OK().setData(contentList);
        }catch (Exception e){
            return Result.ERROR();
        }
    }


}
